//package com.fy.config;
//
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//
//@Slf4j
//@AllArgsConstructor
//@Configuration
//public class MqConfig {
//    private final RabbitTemplate rabbitTemplate;
//
//    //配置路由到交换机成功以后的返回结果数据
//    @PostConstruct
//    public void init() {
//        rabbitTemplate.setReturnsCallback(returned -> {
//            log.error("触发return callback,");
//            log.debug("exchange: {}", returned.getExchange());
//            log.debug("routingKey: {}", returned.getRoutingKey());
//            log.debug("message: {}", returned.getMessage());
//            log.debug("replyCode: {}", returned.getReplyCode());
//            log.debug("replyText: {}", returned.getReplyText());
//        });
//
//        rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
//            if (ack) {
//                log.info("消息发送到交换机成功，相关数据: {}", correlationData);
//            } else {
//                log.error("消息发送到交换机失败，原因: {}", cause);
//            }
//        });
//    }
//}
